package com.xy.biz.base.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.base.domain.req.GetQrCodeBytextRequest;
import com.xy.biz.base.domain.resp.ListQrCodeResponse;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.base.domain.bo.QrCodeBO;
import com.xy.biz.base.domain.po.QrCodePO;
import com.xy.biz.base.domain.query.QrCodeQuery;
import com.xy.biz.base.domain.resp.GetQrCodeResponse;
import com.xy.biz.base.domain.req.SaveQrCodeRequest;
import com.xy.biz.base.domain.req.ListQrCodeRequest;

/**
 * 
 * 
 * @author zgy
 * @date 2021-8-11
 */
public class QrCodeConverter {
	
	public static QrCodePO toPO(QrCodeBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new QrCodePO(), true);
	}
	
	public static List<QrCodePO> toPO(Collection<QrCodeBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new QrCodePO(), true);
	}
	
	public static QrCodeBO fromPO(QrCodePO source) {
		return BeanUtilsEx.copyProperties(source, () -> new QrCodeBO());
	}
	
	public static List<QrCodeBO> fromPO(Collection<QrCodePO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new QrCodeBO());
	}
	
	public static QrCodeBO toBO(SaveQrCodeRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new QrCodeBO(), true);
	}

	public static QrCodeBO toBO(GetQrCodeBytextRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new QrCodeBO(), true);
	}
	
	public static List<QrCodeBO> toBO(Collection<SaveQrCodeRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new QrCodeBO(), true);
	}
	
	public static GetQrCodeResponse toResponse(QrCodeBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetQrCodeResponse());
	}
	
	public static List<GetQrCodeResponse> toResponse(Collection<QrCodeBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetQrCodeResponse());
	}
	public static List<ListQrCodeResponse> toResponse1(Collection<QrCodeBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ListQrCodeResponse());
	}
	
	public static QrCodeQuery toQuery(ListQrCodeRequest source) {
		if(null == source) {
			return null;
		}
		QrCodeQuery target = new QrCodeQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
